-
Notifications
You must be signed in to change notification settings - Fork 97
Closes 5170 adding overloads to reshape #5212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
ajpotts
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this one!
1RyanK
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
| def reshape(self, *shape: int_scalars) -> pdarray: ... | ||
|
|
||
| @overload | ||
| def reshape(self, shape: pdarray) -> pdarray: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add an @overload for numpy arrays?
In [18]: shape_np = np.array([6, 4], dtype=np.int64)
...: try:
...: a.reshape(shape_np)
...: except Exception as e:
...: print(type(e).__name__, e)
...:
TypeError type of argument "shape"[0] must be one of (int, int8, int16, int32, int64, uint8, uint16, uint32, uint64, Sequence, pdarray); got numpy.ndarray insteadThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good idea but it could also be a separate ticket.
Closes #5170.
This adds overloads to reshape.
It also fixes a bug in test_flatten_multidim. The expression
a.reshape(2,2,size/4)has been changed toa.reshape(2,2,size//4). The reason is that size/4 is interpreted as a float, and floats aren't allowed in a shape. This is consistent with numpy.